import { AFFAIRS, BASE } from './api'
import { METHOD, request } from '@/utils/request'

console.log(AFFAIRS)
// 治疗信息
export async function cureList(params) {
  if (localStorage.getItem('admin.roles') == 0) {
    return request(`${BASE}/prisoner/recipe/page`, METHOD.POST, params)
  } else {
    return request(`${BASE}/user/recipe/page`, METHOD.POST, params)
  }
}

// 消费信息
export async function purchaseList(params) {
  if (localStorage.getItem('admin.roles') == 0) {
    return request(`${BASE}/prisoner/cardDetail/page`, METHOD.POST, params)
  } else {
    return request(`${BASE}/user/cardDetail/page`, METHOD.POST, params)
  }

}

// 亲情电话
export async function familyCallList(params) {
  if (localStorage.getItem('admin.roles') == 0) {
    return request(`${BASE}/prisoner/family/page`, METHOD.POST, params)
  } else {
    return request(`${BASE}/user/family/page`, METHOD.POST, params)
  }
}

// 获取所有被监管人员
export async function getAllPrisoner() {
  return request(`${BASE}/user/prisoner/query`, METHOD.POST, {})
}

//  警员分页查询文档列表
export async function getArticleList(params) {
  if (localStorage.getItem('admin.roles') == 0) {
    return request(`${BASE}/prisoner/article/page`, METHOD.POST, params)
  } else {
    return request(`${BASE}/user/article/page`, METHOD.POST, params)
  }
}

// 保存文档
export async function addArticle(params) {
  return request(`${BASE}/user/article/save`, METHOD.POST, params)
}

// 删除文档
export async function delArticle(params) {
  return request(`${BASE}/user/article/del`, METHOD.POST, params)
}

// 下载文档
export async function downloadArticle(params) {
  if (localStorage.getItem('admin.roles') == 0) {
    return request(`${BASE}/prisoner/lookFile/download`, METHOD.FILE, params)
  } else {
    return request(`${BASE}/user/lookFile/download`, METHOD.FILE, params)
  }
}


//下面的接口都是新加的 给监管人员用的 这个上面都是给警员用的，用错了德胜


// 监管人员分页查询文档列表
export async function getPrisonerArticleList(params) {
  return request(`${BASE}/prisoner/article/page`, METHOD.POST, params)
}

// 下载文档
export async function prisonerDownloadArticle(params) {
  return request(`${BASE}/prisoner/lookFile/download`, METHOD.FILE, params)
}

// 治疗信息
export async function getPrisonerCureList(params) {
  return request(`${BASE}/prisoner/recipe/page`, METHOD.POST, params)
}

// 消费信息
export async function getPrisonerPurchaseList(params) {
  return request(`${BASE}/prisoner/cardDetail/page`, METHOD.POST, params)
}

// 亲情电话
export async function getPrisonerFamilyCallList(params) {
  return request(`${BASE}/prisoner/family/page`, METHOD.POST, params)
}


export default {
  cureList,
  purchaseList,
  familyCallList,
  getAllPrisoner,
  getArticleList,
  addArticle,
  delArticle,
  downloadArticle,

  getPrisonerArticleList,
  prisonerDownloadArticle,
  getPrisonerCureList,
  getPrisonerPurchaseList,
  getPrisonerFamilyCallList
}